import http from "../utils/http"

let api = {}

//登录
api.login = params => http.post("/api/sys/login/login", params);
//退出登录
api.logout = params => http.post("/api/sys/login/logout", params);

//统一上传文件
api.upFile = params => http.upload("/api/app/file/up", params);

//用户相关
api.sysUserFindAllByPage = params => http.get("/api/sys/user/findAllByPage", params)
api.sysUserEdit = params => http.post("/api/sys/user/add", params)
api.sysUserAdd = params => http.post("/api/sys/user/edit", params);
api.sysUserDelByIds = ids => http.delete(`/api/sys/user/delByIds/${ids}`);
//获取用户信息
api.sysUserFindProfile = params => http.get("/api/sys/user/findProfile", params);
api.sysUserEditUserProfile = params => http.post("/api/sys/user/edit/profile", params);
api.sysUserEditPassword = params => http.post("/api/sys/user/edit/password", params);
api.sysUserEditAvatar = params => http.post("/api/sys/user/avatar", params);
api.sysUserRePassword = params => http.post("/api/sys/user/rePassword", params);

//菜单相关
api.sysMenuFindAllByTree = params => http.get("/api/sys/menu/findAllByTree", params);
api.sysMenuAdd = params => http.post("/api/sys/menu/add", params);
api.sysMenuEdit = params => http.post("/api/sys/menu/edit", params);
api.sysMenuDelByIds = ids => http.delete(`/api/sys/menu/delByIds/${ids}`, null);
//菜单使用
api.sysMenuFindUserMenuByTree = params => http.get("/api/sys/menu/findUserMenuByTree", params);
api.sysMenuFindSelectByTree = params => {
	if (!params) {
		params = {
			isAll: true
		}
	}
	return http.get("/api/sys/menu/findSelectByTree", params);
}
api.sysMenuFindAllPerByUserId = params => http.get("/api/sys/menu/findAllPerByUserId", params);

//角色相关
api.sysRoleFindAllByPage = params => http.get("/api/sys/role/findAllByPage", params)
api.sysRoleFindAllByList = params => http.get("/api/sys/role/findAllByList", params)
api.sysRoleAdd = params => http.post("/api/sys/role/add", params);
api.sysRoleEdit = params => http.post("/api/sys/role/edit", params);
api.sysRoleDelByIds = ids => http.delete(`/api/sys/role/delByIds/${ids}`, null);

//操作日志
api.sysOperateLogFindAllByPage = params => http.get("api/sys/log/findAllByPage", params)
api.sysOperateLogFindAllByList = params => http.get("api/sys/log/findAllByList", params)
api.sysOperateLogEdit = params => http.post("api/sys/log/edit", params);
api.sysOperateLogAdd = params => http.post("api/sys/log/add", params);
api.sysOperateLogDelByIds = id => http.delete("api/sys/log/delByIds/" + id, null);


//配置相关
api.appConfigFindByType = type => http.get(`/api/app/config/findByType/${type}`, null);
api.appConfigEdit = params => http.post("/api/app/config/edit", params);

//轮播图
api.appLunbotuFindAllByPage = params => http.get("/api/app/lunbotu/findAllByPage", params)
api.appLunbotuEdit = params => http.post("/api/app/lunbotu/edit", params);
api.appLunbotuAdd = params => http.post("/api/app/lunbotu/add", params);
api.appLunbotuDelByIds = id => http.delete("/api/app/lunbotu/delByIds/" + id, null);

//通知
api.appTongzhiFindAllByPage = params => http.get("/api/app/tongzhi/findAllByPage", params)
api.appTongzhiEdit = params => http.post("/api/app/tongzhi/edit", params);
api.appTongzhiAdd = params => http.post("/api/app/tongzhi/add", params);
api.appTongzhiDelByIds = id => http.delete("/api/app/tongzhi/delByIds/" + id, null);

//常见问题
api.appQaFindAllByPage = params => http.get("/api/app/qa/findAllByPage", params)
api.appQaEdit = params => http.post("/api/app/qa/edit", params);
api.appQaAdd = params => http.post("/api/app/qa/add", params);
api.appQaDelByIds = id => http.delete("/api/app/qa/delByIds/" + id, null);

//意见反馈
api.appFankuiFindAllByPage = params => http.get("/api/app/fankui/findAllByPage", params)
api.appFankuiSetState = params => http.post("/api/app/fankui/editState", params)

//字典
api.appDictFindAllByPage = params => http.get("/api/app/dict/findAllByPage", params)
api.appDictFindAllByList = params => http.get("/api/app/dict/findAllByList", params)
api.appDictEdit = params => http.post("/api/app/dict/edit", params);
api.appDictAdd = params => http.post("/api/app/dict/add", params);
api.appDictDelByIds = id => http.delete("/api/app/dict/delByIds/" + id, null);
api.appDictFindByType = type => http.get("/api/app/dict/findByType/" + type, null);
api.appDictInit = params => http.get("/api/app/dict/init", params)

//字典-数据
api.appDictDataFindAllByPage = params => http.get("/api/app/dict/data/findAllByPage", params)
api.appDictDataFindAllByList = params => http.get("/api/app/dict/data/findAllByList", params)
api.appDictDataEdit = params => http.post("/api/app/dict/data/edit", params);
api.appDictDataAdd = params => http.post("/api/app/dict/data/add", params);
api.appDictDataDelByIds = id => http.delete("/api/app/dict/data/delByIds/" + id, null);

//自动生成工具
api.appGenTableFindAllByPage = params => http.get("/api/code/gen/table/findAllByPage", params)
api.appGenTableFindAllByList = params => http.get("/api/code/gen/table/findAllByList", params)
api.appGenTableDbFindAllByPage = params => http.get("/api/code/gen/table/db/findAllByPage", params)
api.appGenTableColumnByTableId = tableId => http.get(`/api/code/gen/table/column/${tableId}`,null)
api.appGenTableImportTable = params => http.post(`/api/code/gen/table/importTable`,params)
api.appGenTableEdit = params => http.post("/api/code/gen/table/edit", params);
api.appGenTableAdd = params => http.post("/api/code/gen/table/add", params);
api.appGenTableDelByIds = id => http.delete("/api/code/gen/table/delByIds/" + id, null);
api.appGenTablePreviewByTableId = tableId => http.get(`/api/code/gen/table/preview/${tableId}`,null)
api.appGenTableDownloadByTableId = params => http.download(`/api/code/gen/table/download/${params.id}`,params)
api.appGenTableFindById = tableId => http.get(`/api/code/gen/table/findById/${tableId}`)
api.appGenTableGenCodeById = id => http.post("/api/code/gen/table/genCodeById/" + id, null);
api.appGenTableTongbuById = id => http.get(`/api/code/gen/table/tongbuById/${id}`, null);

//资源
api.appResourceFindAllByPage = params => http.get("/api/app/resource/findAllByPage", params)
api.appResourceFindAllByList = params => http.get("/api/app/resource/findAllByList", params)
api.appResourceEdit = params => http.post("/api/app/resource/edit", params);
api.appResourceAdd = params => http.post("/api/app/resource/add", params);
api.appResourceDelByIds = id => http.delete("/api/app/resource/delByIds/" + id, null);

//用户相关
api.appUserFindAllByPage = params => http.get("/api/app/user/findAllByPage", params)

//格子模板
api.appTmplFindAllByPage = params => http.get("/api/code/tmpl/findAllByPage", params)
api.appTmplFindAllByList = params => http.get("/api/code/tmpl/findAllByList", params)
api.appTmplEdit = params => http.post("/api/code/tmpl/edit", params);
api.appTmplAdd = params => http.post("/api/code/tmpl/add", params);
api.appTmplDelById = id => http.delete("/api/code/tmpl/delByIds/" + id, null);
api.appTmplImportData = params => http.upload("/api/code/tmpl/importData", params,{
	isErrorToast:false
});
api.appTmplImportTemplate = (params) => http.download("/api/app/tmpl/importTemplate", params);
api.appTmplExportData = (params) => http.download("/api/app/tmpl/exportData", params);

//APP-资源
api.appResourceCopy1FindAllByPage = params => http.get("/api/app/resource/copy1/findAllByPage", params)
api.appResourceCopy1FindAllByList = params => http.get("/api/app/resource/copy1/findAllByList", params)
api.appResourceCopy1Edit = params => http.post("/api/app/resource/copy1/edit", params);
api.appResourceCopy1Add = params => http.post("/api/app/resource/copy1/add", params);
api.appResourceCopy1DelById = id => http.delete("/api/app/resource/copy1/delByIds/" + id, null);
api.appResourceCopy1ImportData = params => http.upload("/api/app/resource/copy1/importData", params,{isErrorToast:false});
api.appResourceCopy1ImportTemplate = (params) => http.download("/api/app/resource/copy1/importTemplate", params);


//闫伟测试
api.appCodeFindAllByPage = params => http.get("/api/app/code/findAllByPage", params)
api.appCodeFindAllByList = params => http.get("/api/app/code/findAllByList", params)
api.appCodeFindById = id => http.get("/api/app/code/findById/" + id, null);
api.appCodeEdit = params => http.post("/api/app/code/edit", params);
api.appCodeAdd = params => http.post("/api/app/code/add", params);
api.appCodeDelById = id => http.delete("/api/app/code/delByIds/" + id, null);
api.appCodeImportData = params => http.upload("/api/app/code/importData", params,{isErrorToast:false});
api.appCodeImportTemplate = (params) => http.download("/api/app/code/importTemplate", params);
api.appCodeExportData = (params) => http.download("/api/app/code/exportData", params);

export default api